home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 68161 / 68161.xpi / chrome / content / sidebar-overlay.js < prev    next >
Text File  |  2010-01-28  |  2KB  |  80 lines

  1. /**
  2.  * A class to assist the browser overlay dialog
  3.  * 
  4.  * @class
  5.  */
  6. var TwitOverlay = {
  7.     /**
  8.      * The service responsible for retrieving and setting preferences
  9.      */
  10.     prefService: Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch2),
  11.     /**
  12.      * Service used to manipulate XUL dialogs
  13.      */
  14.     windowService: Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator),
  15.     
  16.     /**
  17.      * Retrieve a preference
  18.      * 
  19.      * @param {String} aName The name of the preference.
  20.      * @param {String} aDefault A default value to return if something goes wrong.
  21.      * @returns {Mixed} The preference's value or aDefault on error.
  22.      * @methodOf TwitOverlay
  23.      * @since 1.0
  24.      */
  25.     getPref:
  26.         function (aName, aDefault) {
  27.             try {
  28.                 var pb = this.prefService;
  29.                 switch ( pb.getPrefType(aName) ) {
  30.                     case pb.PREF_STRING:
  31.                         return pb.getCharPref(aName);
  32.                     case pb.PREF_BOOL:
  33.                         return pb.getBoolPref(aName);
  34.                     case pb.PREF_INT:
  35.                         return pb.getIntPref(aName);
  36.                 }
  37.             } catch ( e ) { }
  38.             return aDefault;
  39.         },
  40.     /**
  41.      * Open TwitKitplus's Preferences window
  42.      * 
  43.      * @methodOf TwitOverlay
  44.      * @since 1.0
  45.      */
  46.     openPrefs:
  47.         function () {
  48.             var dialog = this.windowService.getMostRecentWindow("TwitKitplus:Preferences");
  49.             if (dialog) {
  50.                 dialog.focus();
  51.                 return;
  52.             }
  53.             openDialog(
  54.                 "chrome://twitkitplus/content/preferences.xul",
  55.                 "_blank",
  56.                 "chrome,titlebar,centerscreen"
  57.             );
  58.         },
  59.     /**
  60.      * Open TwitKitplus's About window
  61.      * 
  62.      * @methodOf TwitOverlay
  63.      * @since 1.0
  64.      */
  65.     openAbout:
  66.         function () {
  67.             var dialog = this.windowService.getMostRecentWindow("TwitKitplus:About");
  68.             if ( dialog ) {
  69.                 dialog.focus();
  70.                 return;
  71.             }
  72.             openDialog(
  73.                 "chrome://twitkitplus/content/about.xul",
  74.                 "_blank",
  75.                 "chrome,titlebar,centerscreen," +
  76.                 ( ( this.getPref("browser.preferences.instantApply", false ) ) ? "dialog=no" : "modal" )
  77.             );
  78.         }
  79. };
  80.